# -*- coding: utf-8 -*-
# flake8: noqa

from qiniu import Auth, put_file, etag, Zone, set_default

access_key = 'wkJupck8Ylduede0ny9KSsIG4vqwDkelgBfejKSv'
secret_key = 'i4UrEdihv93LUun8MMG_OCAcGQHwPU6ZiHq5ijMg'
q = Auth(access_key, secret_key)
bucket_name = 'lxhlxhlxh'
key = 'test1.jpg'
token = q.upload_token(bucket_name, key, 3600)
print(token)
localfile = '/Users/lixianhe/Downloads/WPS_Office_Installer.zip'

# zone = Zone(
#     up_host='free-qvm-z1-zz.qiniup.com',
#     up_host_backup='free-qvm-z1-zz.qiniup.com',
#     io_host='iovip.qbox.me',
#     scheme='http')
# set_default(default_zone=zone)

ret, info = put_file(token, key, localfile, version='v2')
print(info)
assert ret['key'] == key
assert ret['hash'] == etag(localfile)